package org.jxc.service;
 
import java.util.List;

import org.hibernate.SessionFactory;
import org.jxc.dao.ProductionProductDAO;
import org.jxc.domain.ProductionProduct;
import org.springframework.beans.factory.annotation.Autowired;
import org.team4.dao.DAOFactory;
import org.team4.exception.CRUDException;
import org.team4.service.IService;
import org.team4.vo.Page;

public class ProductionProductService implements IService {

	private ProductionProductDAO dao ;
	
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		dao = (ProductionProductDAO) DAOFactory.getDAO(sessionFactory, ProductionProductDAO.class);
	}

	public Page<ProductionProduct> listPagination(Page<ProductionProduct> page) throws CRUDException {
		return dao.pagination(page, "from ProductionProduct where deleteFlag = '0'", null);
	}

	public void save(ProductionProduct object) throws CRUDException {
		dao.save(object);
	}

	public List<ProductionProduct> getListByProductionOrderId(String id) throws CRUDException {
		return dao.find(" from ProductionProduct where productionOrder.id = '" + id + "'", null);
	}

	public void update(ProductionProduct productionProduct) throws CRUDException {
		dao.update(productionProduct);
	}

}
